<template>
  <div class="category-menu">
    <scroll ref="scroll" class="content" :pullUpLoad="true" :probeType="3">
      <div
        v-for="(item,index) in category"
        :key="index"
        @click="itemClick(index)"
        :class="{'active':currentIndex === index}"
      >{{item.title}}</div>
    </scroll>
  </div>
</template>

<script>
import Scroll from "components/common/scroll/Scroll";

export default {
  name: "CategoryMenu",
  data() {
    return {
      currentIndex: 0,
    };
  },
  props: {
    category: {
      type: Array,
      default() {
        return [];
      },
    },
  },
  components: {
    Scroll,
  },

  methods: {
    itemClick(index) {
      this.currentIndex = index;
      this.$emit("itemClick", index);
    },
  },
};
</script>

<style scoped>
.category-menu {
  background-color: #eee;
  width: 25%;
  text-align: center;
  font-size: 14px;
  height: 100%;
  line-height: 50px;
}
.content {
  background: #f6f6f6;
  height: calc(100vh - 44px - 49px);
  overflow: hidden;
}
.active {
  border-left: 3px solid var(--color-high-text);
  color: var(--color-high-text);
  background-color: #fff;
}
</style>